package com.caozhi.mspeoject.nb_search.controller;

import com.caozhi.mspeoject.nb_search.repository.UserSearchRepository;
import com.woniuxy.boot.common.bean.EsUser;
import com.woniuxy.boot.common.dto.EsUserSearchDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("userSearch")
public class UserSearchController {
    @Autowired
    private UserSearchRepository searchRepository;
    @PostMapping("get")
    public List<EsUser> getEsUser(@RequestBody EsUserSearchDTO esUserSearchDTO) {
        if(esUserSearchDTO.getKeyword() == null){
            return searchRepository.findByNameOrPhoneOrIdCard(null , null , null);
        }
        return searchRepository.findByNameOrPhoneOrIdCard(esUserSearchDTO.getKeyword() , esUserSearchDTO.getKeyword() ,esUserSearchDTO.getKeyword() );
    }

}
